function clear_info()
{
	document.getElementById('name').value = '';
	document.getElementById('email').value = '';
	document.getElementById('title').value = '';
	document.getElementById('message').value = '';
}
function isValidForm()
{
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	var captcha = document.getElementById('recaptcha_response_field');
	var message = document.getElementById('message');
	var form = document.getElementById('contact-form');
	var error_message = document.getElementById('error-message')
	if  (error_message !== null) {
		var wrapper = document.getElementById('contact-wrapper');
		wrapper.removeChild(error_message);
	}
	var error = 0;
	if (name.value == '') {
		var error = document.createElement("label");
		error.setAttribute('class','error-mess');
		error.innerHTML = ' (This field is required)';
		form.insertBefore(error,name);
		error = 1;
	}
	if (email.value == '') {
		var error = document.createElement("label");
		error.setAttribute('class','error-mess');
		error.innerHTML = ' (This field is required)';
		form.insertBefore(error,email);
		error = 1;
	}
	else {
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email.value)) {
			var error = document.createElement("label");
			error.setAttribute('class','error-mess');
			error.innerHTML = ' (This field is invalid)';
			form.insertBefore(error,email);
			error = 1;
		}
	}
	if (captcha.value == '') {
		var error = document.createElement("label");
		error.setAttribute('class','error-mess');
		error.innerHTML = ' (This field is required)';
		var recaptcha = document.getElementById('recaptcha_widget_div');
		form.insertBefore(error,recaptcha);
		error = 1;
	}
	if (message.value == '') {
		var error = document.createElement("label");
		error.setAttribute('class','error-mess');
		error.innerHTML = ' (This field is required)';
		form.insertBefore(error,message);
		error = 1;
	}
	if (error == 0) {
		form.submit();
		return true;
	}
	else {
		
		return false;
	}
}

$(document).ready(function() {
	$('#slider').nivoSlider();
    $sliderNavPos = ($('#slider').width() - $('.nivo-controlNav').width())/2;
    $('.nivo-controlNav').css('left',$sliderNavPos);
    
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active"); 
		$('.tab-content').hide().removeClass("active");

		var activeTab = $(this).find("a").attr("href"); 
		$(activeTab).show().addClass("active");
		return false;
	});
	$(window).scroll(function(){
		if($(this).scrollTop()!=0){
			$('#bttop').fadeIn();}
		else{
			$('#bttop').fadeOut();
		}
	});
	$('#bttop span').click(function(){
		$('body,html').animate({scrollTop:0},800);
	});
	$(".mainmenu li").each(function(){
		var $sublist = $(this).find('ul:first');
		$(this).hover(function(){
			$sublist.stop().css({overflow:"hidden",height:"auto",display:"none"}).slideDown(400,function(){
				$(this).css({overflow:"visible",height:"auto"});
			});
		},function(){
			$sublist.stop().slideUp(400,function(){
				$(this).css({overflow:"hidden",display:"none"});
			});
		});
	});
	$('#emot').click(function(){
		$('#emot-wrapper').slideToggle(400);
		return false;
	});
});